home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 March / EnigmA AMIGA RUN 05 (1996)(G.R. Edizioni)(IT)[!][issue 1996-03][Skylink CD IV].iso / earcd / comm2 / amislt14.lha / AmiSlate / SlateRexx / reversi.rexx < prev    next >
OS/2 REXX Batch file  |  1996-01-27  |  19KB  |  638 lines

  1. /* Reversi for AmiSlate v1.1! */
  2. /* This program should be run on a screen with at least 4 colors */
  3.  
  4. /* Get our host's name--always given as first argument when run from Amislate */
  5. parse arg CommandPort ActiveString
  6.  
  7. if (length(CommandPort) == 0) then do
  8.     say ""
  9.     say "Usage:  rx reversi.rexx <REXXPORTNAME>"
  10.     say "        (REXXPORTNAME is usually AMISLATE)"
  11.     say ""
  12.     say "Or run from the Rexx menu within AmiSlate."
  13.     say ""
  14.     exit 0
  15.     end
  16.     
  17. /* Send all commands to this host */
  18. address (CommandPort) 
  19. options results
  20.  
  21. lock ON
  22.  
  23. /* See if we're connected */
  24. GetRemoteStateAttrs stem rstateattrs.
  25. if (rstateattrs.mode > -1) then do
  26.         /* Parse command line argument to see if we've been activated by 
  27.            a remote request or a local user */
  28.         check = upper(left(ActiveString,3))
  29.         if (upper(left(ActiveString,3)) ~= 'RE') then 
  30.             GlobData.localplayer = 1
  31.         else
  32.             GlobData.localplayer = -1
  33.         end
  34.     else do
  35.         GlobData.localplayer = 0    /* i.e. we're both players */
  36.         end
  37.         
  38. if (GlobData.localplayer > 0) then do
  39.     call SetStatus("Requesting game from remote user... please wait.")
  40.     RemoteRexxCommand '"'||"Would you like to play Reversi?"||'"' "slaterexx:reversi.rexx"
  41.     
  42.         waitevent stem handshake. MESSAGE
  43.         if (handshake.message == 0) then 
  44.         do
  45.             call SetStatus("Reversi Game Refused")
  46.             lock off
  47.             exit 0
  48.         end
  49.     end
  50.  
  51. call SetStatus("Beginning Reversi...")
  52.  
  53. call ResetGameState
  54. call SetGlobalData
  55. if (GlobData.localplayer >= 0) then call DrawBoard
  56.  
  57. call NextTurn
  58. call HandleEvents
  59.  
  60. lock OFF
  61. exit 0
  62.  
  63. /* Global Data structure:
  64.  
  65.     GlobData.Xspace.[step] (int)     : horizontal pixel offsets to the center of each coord (0-16)
  66.     GlobData.XSize    (int)         : total width of each element
  67.     GlobData.Yspace.[step] (int)     : vertical pixel offsets to the center of each coord (0-16)
  68.     GlobData.YSize    (int)         : total height of each element
  69.  
  70.     (board state)
  71.     GlobData.board.[0..8].[0..8]     : two-dimensional board array
  72.     
  73.     (game state)
  74.     GlobData.turn             : whose turn it is
  75.     GlobData.localplayer              : which player is on local machine; 0 if both are
  76.  
  77.      (color info)
  78.     GlobData.PieceColor.[playernum]  : color of pieces for this player
  79.  
  80. */
  81.  
  82. /* --------------------------------------------------------------- */
  83. /* procedure HandleEvents                        */
  84. /* --------------------------------------------------------------- */
  85. HandleEvents: procedure expose GlobData. AMessage.
  86.  
  87. AMessage.TIMEOUT     = 1    /* No events occurred in specified time period */
  88. AMessage.MESSAGE     = 2    /* Message recieved from remote Amiga */
  89. AMessage.MOUSEDOWN   = 4    /* Left mouse button press in drawing area */
  90. AMessage.MOUSEUP     = 8    /* Left mouse button release in drawing area */
  91. AMessage.RESIZE      = 16    /* Window was resized--time to redraw screen? */ 
  92. AMessage.QUIT        = 32    /* AmiSlate is shutting down */
  93. AMessage.CONNECT     = 64    /* Connection established */
  94. AMessage.DISCONNECT  = 128    /* Connection broken */
  95. AMessage.TOOLSELECT  = 256    /* Tool Selected */
  96. AMessage.COLORSELECT = 512    /* Palette Color selected */
  97. AMessage.KEYPRESS    = 1024    /* Key pressed */
  98. AMessage.MOUSEMOVE   = 2048     /* Mouse was moved */
  99.  
  100. do while(1)
  101.     waitevent stem event. RESIZE MOUSEDOWN MOUSEUP TOOLSELECT MESSAGE DISCONNECT
  102.  
  103.     if (event.type == AMessage.QUIT) then exit 0
  104.     
  105.     if (event.type == AMessage.DISCONNECT) then do
  106.         call SetStatus("Connection broken--both players now local.")
  107.         GlobData.localplayer = 0
  108.         end
  109.    
  110.     if (event.type == AMessage.MESSAGE) then do
  111.         parse var event.message rx ry
  112.         call PlaceMove((rx+0), (ry+0), 0)  /* update our internals--the (+0) forces the vars back into numeric format */
  113.         call NextTurn
  114.         end
  115.  
  116.     if (event.type == AMessage.TOOLSELECT) then do
  117.         /* Check to see if the new player has a move available */
  118.         call SetStatus("Checking to see if a move is available!")
  119.     if (CanMove() == 0) then do
  120.         GlobData.playercantmove = GlobData.turn
  121.         call SetStatus("Sorry, but you must forfeit your turn.")
  122.         call Delay(50)
  123.         call NextTurn
  124.         end
  125.     else do
  126.         call SetStatus("Actually, there IS a move available!  Find it!")
  127.         GlobData.playercantmove = 0
  128.         end    
  129.     end
  130.  
  131.     if (event.type == AMessage.RESIZE) then do
  132.         if ((GlobData.localplayer == GlobData.turn)|(GlobData.localplayer == 0)) then do
  133.             cturn = GlobData.turn
  134.             call SetGlobalData
  135.             call DrawBoard
  136.             call ColorBorder(GlobData.PieceColor.cturn)
  137.             call SetStatus("_LAST")
  138.         end
  139.         else do
  140.             /* else just update our internal vars */
  141.             call SetGlobalData
  142.             call SetStatus("_LAST")
  143.         end
  144.     end
  145.     
  146.     if ((event.type == AMessage.MOUSEDOWN)&((GlobData.turn = GlobData.localplayer)|(GlobData.localplayer == 0))) then do
  147.         whatclickedx = ChopRange(trunc((event.x-GlobData.BORDER_H)/(GlobData.XSize)),0,7)
  148.         whatclickedy = ChopRange(trunc((event.y-GlobData.BORDER_V)/(GlobData.YSize)),0,7)       
  149.         if (MoveOkay(whatclickedx, whatclickedy) == 1) then do
  150.             call PlaceMove(whatclickedx, whatclickedy, 1)
  151.             if (GlobData.localplayer ~= 0) then call TransmitMove(whatclickedx, whatclickedy)
  152.             call NextTurn
  153.             end
  154.     end
  155.     end
  156.     return 1
  157.  
  158.  
  159. /* --------------------------------------------------------------- */
  160. /* procedure NextTurn                           */
  161. /*                                    */
  162. /* --------------------------------------------------------------- */
  163. NextTurn: procedure expose GlobData.
  164.     /* Swap turns */
  165.     GlobData.turn = -GlobData.turn
  166.  
  167.     negone = -1
  168.     
  169.     player.1 = "Player 1"
  170.     player.negone = "Player 2"
  171.     cturn = GlobData.turn
  172.     
  173.     if (GlobData.turn == GlobData.localplayer) then call ColorBorder(0)
  174.     
  175.     scores = "(P1:"||GlobData.pieces.1||" P2:"||GlobData.pieces.negone||")"
  176.     
  177.     /* Check for wins */
  178.     if (GlobData.pieces.1 <= 0) then do
  179.         call ColorBorder(GlobData.PieceColor.negone)
  180.         GameWon("Player 2")
  181.         end
  182.         
  183.     if (GlobData.pieces.negone <= 0) then do
  184.         call ColorBorder(GlobData.PieceColor.1)
  185.         call GameWon("Player 1")
  186.         end
  187.         
  188.     if (GlobData.pieces.1 + GlobData.pieces.negone >= 64) then do
  189.         if (GlobData.pieces.1 > GlobData.pieces.negone) then do 
  190.             call ColorBorder(GlobData.PieceColor.1)
  191.             call GameWon("Player 1")
  192.             end
  193.         if (GlobData.pieces.1 < GlobData.pieces.negone) then do
  194.             call ColorBorder(GlobData.PieceColor.negone)
  195.             call GameWon("Player 2")
  196.             end
  197.         if (GlobData.pieces.1 == GlobData.pieces.negone) then do 
  198.             call ColorBorder(0)
  199.             call GameWon("Tie")
  200.             end
  201.         end        
  202.     
  203.     /* local game code */
  204.     if (Globdata.localplayer == 0) then do
  205.         call SetStatus(player.cturn || ", it's your turn to place a stone. "||scores)
  206.         call ColorBorder(GlobData.PieceColor.cturn)
  207.         return 1
  208.         end
  209.     
  210.     /* two machine game code */
  211.     if (GlobData.turn == GlobData.localplayer) then do
  212.         call SetStatus(player.cturn || ", it's your turn to place a stone. "||scores)
  213.         call ColorBorder(GlobData.PieceColor.cturn)
  214.         end    
  215.     else call SetStatus("Wait for other player to move. "||scores)    
  216.     return 1
  217.  
  218.  
  219. /* --------------------------------------------------------------- */
  220. /* procedure ColorBorder                       */
  221. /*                                    */
  222. /* Colors the border the color indicated in the param            */
  223. /*                                   */
  224. /* --------------------------------------------------------------- */
  225. ColorBorder: procedure expose GlobData.
  226.     parse arg color
  227.     
  228.     SetFPen color
  229.     
  230.     /* Fill each side of the border with a square */
  231.     /* rely on AmiSlate's clipping to deal with extra material */
  232.     square 0 0 10000 (GlobData.YSpace.0)-1 FILL
  233.     square 0 0 (GlobData.XSpace.0)-1 10000 FILL
  234.     square (GlobData.XSpace.8)+1 0 10000 10000 FILL
  235.     square 0 (GlobData.YSpace.8)+1 10000 10000 FILL
  236.     return 1
  237.     
  238.  
  239. /* --------------------------------------------------------------- */
  240. /* procedure CanMove                           */
  241. /*                                    */
  242. /* Returns 1 if there is a move available for the current player   */
  243. /* else 0                               */
  244. /*                                    */
  245. /* --------------------------------------------------------------- */
  246. CanMove: procedure expose GlobData.
  247.     
  248.     num1 = 0
  249.     num2 = 0
  250.     negone = -1
  251.     
  252.     do i = 0 to 7
  253.         do j = 0 to 7
  254.              if (GlobData.board.i.j == 1) then 
  255.                  num1 = num1 + 1
  256.              else 
  257.                  if (GlobData.board.i.j == -1) then num2 = num2 + 1
  258.  
  259.             if (MoveOkay(i,j) == 1) then return 1
  260.         end
  261.     end
  262.     
  263.     /* If we got here there must not be an available move. */
  264.     /* If it's because the board is filled, then the game is over! */
  265.     if (((num1 + num2) == 64)|(GlobData.playercantmove*GlobData.turn == -1)) then do
  266.         if (num1 > num2) then do
  267.             call ColorBorder(GlobData.PieceColor.1)
  268.             call GameWon("Player 1")
  269.             end
  270.         else if (num1 < num2) then do
  271.             call ColorBorder(GlobData.PieceColor.negone)
  272.             call GameWon("Player 2")
  273.             end
  274.         else do
  275.             call ColorBorder(0)
  276.             call GameWon("Tie")
  277.             end
  278.         end
  279.  
  280.     /* If it's because one of the players has no pieces left, then 
  281.        the game is also over! */
  282.     if (num1 == 0) then do
  283.         call ColorBorder(GlobData.PieceColor.negone)
  284.         call GameWon("Player 2")
  285.         end
  286.     if (num2 == 0) then do
  287.         call ColorBorder(GlobData.PieceColor.1)
  288.         call GameWon("Player 1")
  289.         end
  290.         
  291.     /* otherwise there just wasn't a move available */
  292.     return 0
  293.  
  294.  
  295. /* --------------------------------------------------------------- */
  296. /* procedure GameWon                           */
  297. /*                                    */
  298. /* displays a message saying who won, based on the arg, and exits. */
  299. /*                                   */
  300. /* --------------------------------------------------------------- */
  301. GameWon: procedure expose GlobData.
  302.     parse arg winner
  303.     
  304.     negone = -1
  305.     
  306.     if (winner == "Tie") then winstring = "The game ends in a tie."
  307.     else winstring = winner || " has won the game!"
  308.     
  309.     EasyRequest "Winner!" '"'||winstring||'"' "Okay"
  310.     call SetStatus("Game Over.  Final Scores:  P1:" || GlobData.pieces.1 || " P2:" || GlobData.pieces.negone)
  311.     lock off
  312.     exit 0
  313.     
  314.  
  315. /* --------------------------------------------------------------- */
  316. /* procedure PlaceMove                           */
  317. /*                                    */
  318. /* does a move by placing a piece at (x,y) and turning over all    */
  319. /* appropriate pieces                           */
  320. /*                                   */
  321. /* --------------------------------------------------------------- */
  322. PlaceMove: procedure expose GlobData.
  323.     parse arg x,y, draw
  324.     
  325.     call SetBoardSquare(x,y,GlobData.turn)
  326.     if (draw == 1) then call DrawPiece(x,y, draw)
  327.     if (BracketAvailable(x,y,-1,-1)) then call DrawBracket(x,y,-1,-1, draw)
  328.     if (BracketAvailable(x,y,0,-1))  then call DrawBracket(x,y,0,-1, draw)
  329.     if (BracketAvailable(x,y,1,-1))  then call DrawBracket(x,y,1,-1, draw)
  330.     if (BracketAvailable(x,y,1,0))   then call DrawBracket(x,y,1,0, draw)
  331.     if (BracketAvailable(x,y,1,1))   then call DrawBracket(x,y,1,1, draw)
  332.     if (BracketAvailable(x,y,0,1))   then call DrawBracket(x,y,0,1, draw)
  333.     if (BracketAvailable(x,y,-1,1))  then call DrawBracket(x,y,-1,1, draw)
  334.     if (BracketAvailable(x,y,-1,0))  then call DrawBracket(x,y,-1,0, draw)
  335.     return 1
  336.  
  337.  
  338. /* --------------------------------------------------------------- */
  339. /* procedure MoveOkay                           */
  340. /*                                    */
  341. /* returns 1 if move is acceptable, or -1 if it is illegal.       */
  342. /*                                    */
  343. /* --------------------------------------------------------------- */
  344. MoveOkay: procedure expose GlobData.
  345.     parse arg x, y
  346.  
  347.     negone = -1
  348.     
  349.     /* first rule: you can only place a stone where there isn't one */
  350.     if (GlobData.board.x.y ~= 0) then return 0
  351.     
  352.     /* The only other rule: there must be a "bracket pair" in a direction */
  353.  
  354.     /* Try north first */
  355.     if (BracketAvailable(x,y,0,-1)  == 1) then return 1
  356.     if (BracketAvailable(x,y,0,1)   == 1) then return 1
  357.     if (BracketAvailable(x,y,-1,0)  == 1) then return 1
  358.     if (BracketAvailable(x,y,1,0)   == 1) then return 1
  359.     if (BracketAvailable(x,y,-1,-1) == 1) then return 1
  360.     if (BracketAvailable(x,y,1,-1)  == 1) then return 1
  361.     if (BracketAvailable(x,y,-1,1)  == 1) then return 1
  362.     if (BracketAvailable(x,y,1,1)   == 1) then return 1
  363.     
  364.     /* No move available */    
  365.     return 0
  366.     
  367.  
  368. /* --------------------------------------------------------------- */
  369. /* procedure BracketAvailable                       */
  370. /*                                   */
  371. /* Searches for an "us-them[...-them]-us" pattern in the direction */
  372. /* indicated by dx and dy.                        */
  373. /*                                   */
  374. /* --------------------------------------------------------------- */
  375. BracketAvailable: procedure expose GlobData.
  376.     parse arg x,y,dx,dy
  377.  
  378.     /* move off of the square-in-question... */
  379.     x = x + dx
  380.     y = y + dy
  381.  
  382.     /* Shortcut--if they aren't next to us, nevermind */
  383.     if ((GlobData.board.x.y * GlobData.turn) ~= -1) then return 0    
  384.     
  385.     /* default */
  386.     BFoundMiddle = 0
  387.         
  388.     do while ((x>=0)&(y>=0)&(x<=7)&(y<=7))
  389.         /* We hit a blank--no end on our bracket */
  390.         if (GlobData.board.x.y == 0) then return 0
  391.         
  392.         /* We hit our own piece--okay iff we saw theirs beforehand */
  393.         if (GlobData.board.x.y == GlobData.turn) then return BFoundMiddle
  394.  
  395.         /* We hit their piece--make a note of it */
  396.         if (GlobData.board.x.y == -GlobData.turn) then BFoundMiddle = 1
  397.  
  398.         /* advance to next square */
  399.         x = x + dx
  400.         y = y + dy
  401.         end
  402.     
  403.     /* Nope, ran off board */    
  404.     return 0
  405.     
  406.  
  407.  
  408. /* --------------------------------------------------------------- */
  409. /* procedure DrawBracket                       */
  410. /*                                   */
  411. /* Flips the counters for all of the other side's pieces in the    */
  412. /* given bracket.                            */
  413. /*                                   */
  414. /* --------------------------------------------------------------- */
  415. DrawBracket: procedure expose GlobData.
  416.     parse arg x,y,dx,dy,draw
  417.         
  418.     /* move off of the square-in-question... */
  419.     x = x + dx
  420.     y = y + dy
  421.  
  422.     do while ((x>=0)&(y>=0)&(x<=7)&(y<=7))    
  423.         /* We hit our own piece--we're all done */
  424.         if (GlobData.board.x.y == GlobData.turn) then return 1
  425.  
  426.         /* We hit their piece--flip it! */
  427.         if (GlobData.board.x.y == -GlobData.turn) then do
  428.             call SetBoardSquare(x,y,GlobData.turn)
  429.             if (draw == 1) then call DrawPiece(x,y,draw)
  430.             end
  431.  
  432.         /* advance to next square */
  433.         x = x + dx
  434.         y = y + dy
  435.         end
  436.  
  437.     /* Nope, ran off board */
  438.     return 0
  439.     
  440.  
  441. /* --------------------------------------------------------------- */
  442. /* procedure ResetGameState                       */
  443. /* --------------------------------------------------------------- */
  444. ResetGameState: procedure expose GlobData.
  445.     negone = -1;
  446.     
  447.     GlobData.turn = -1;
  448.     
  449.     /* first clear the board */
  450.     do i = -1 to 8
  451.         do j = -1 to 8
  452.             GlobData.board.i.j = 0
  453.         end
  454.     end
  455.  
  456.     /* then add in initial pieces */
  457.     GlobData.board.3.3 = 1
  458.     GlobData.board.4.4 = 1
  459.     GlobData.board.4.3 = -1
  460.     GlobData.board.3.4 = -1
  461.  
  462.     /* Our infinite loop avoidance hack ;) */
  463.     GlobData.playercantmove = 0
  464.     
  465.     GlobData.pieces.1 = 2
  466.     GlobData.pieces.negone = 2
  467.     
  468.     return 1
  469.  
  470. /* --------------------------------------------------------------- */
  471. /* procedure SetGlobalData                       */
  472. /* --------------------------------------------------------------- */
  473. SetGlobalData: procedure expose GlobData.
  474.     negone = -1
  475.     
  476.     /* constants */
  477.     GlobData.BORDER_H = 5
  478.     GlobData.BORDER_V = 10
  479.     
  480.     /* Check to see whether we are connected */
  481.        GetWindowAttrs stem winattrs.
  482.        BoardWidth = winattrs.width  - 58 - (GlobData.BORDER_H*2)
  483.        BoardHeight= winattrs.height - 55 - (GlobData.BORDER_V*2)
  484.  
  485.     /* Set up offsets */
  486.     DO i=0 to 8
  487.       GlobData.Xspace.i = trunc(BoardWidth  * i / 8) + GlobData.BORDER_H
  488.       GlobData.Yspace.i = trunc(BoardHeight * i / 8) + GlobData.BORDER_V
  489.       end
  490.  
  491.     GlobData.XSize = trunc(BoardWidth / 8)
  492.     GlobData.YSize = trunc(BoardHeight / 8)
  493.  
  494.        if (winattrs.depth < 2) then do
  495.         EasyRequest Reversi_Error '"'||"You need at least a 4-color screen to play Reversi!"||'"' '"'||"Abort Reversi"||'"'
  496.         call SetStatus("Reversi game exited.")
  497.         lock off
  498.         exit 0
  499.         end 
  500.  
  501.     GlobData.PieceColor.1 = 2
  502.     GlobData.PieceColor.negone = 3
  503.     return 1
  504.  
  505.  
  506. /* --------------------------------------------------------------- */
  507. /* procedure DrawBoard                                             */
  508. /* --------------------------------------------------------------- */
  509. DrawBoard: procedure expose GlobData.
  510.     SetFColor 0 0 0        /* Get a black pen */
  511.  
  512.     Clear
  513.  
  514.     SetWindowTitle '"' || "Hang on, drawing the board..." || '"'
  515.     call SetColors
  516.     
  517.     SetFPen 1
  518.     do i = 0 to 8
  519.         line GlobData.XSpace.i GlobData.YSpace.0 GlobData.XSpace.i GlobData.YSpace.8
  520.         line GlobData.XSpace.0 GlobData.YSpace.i GlobData.XSpace.8 GlobData.YSpace.i
  521.         end
  522.         
  523.     do i = 0 to 7
  524.         do j = 0 to 7
  525.             if (GlobData.Board.i.j ~= 0) then call DrawPiece(i,j)
  526.             end
  527.         end
  528.         
  529.     call SetStatus("_LAST")
  530.     return 1
  531.  
  532.  
  533. /* Draws the piece listed at coords xc, yc */
  534. DrawPiece: procedure expose GlobData.
  535.     parse arg xc, yc
  536.  
  537.     piece = GlobData.board.xc.yc
  538.     if (piece == 0) then return 0
  539.     
  540.     /* Draw the piece in the square on the LOWER RIGHT of this intersection */
  541.     cx = MidwayBetween(xc,xc+1,X)
  542.     cy = MidwayBetween(yc,yc+1,Y)    
  543.     
  544.     SetFPen GlobData.PieceColor.piece
  545.     circle cx cy trunc(GlobData.XSize/3) trunc(GlobData.YSize/3) FILL
  546.     SetFPen 1
  547.     circle cx cy trunc(GlobData.XSize/3) trunc(GlobData.YSize/3) 
  548.     return 1
  549.  
  550.  
  551. /* Updates the internal counts and board as specified by the
  552.    move in the arguments */
  553. SetBoardSquare: procedure expose GlobData.
  554.     parse arg x, y, player
  555.  
  556.     opponent = -player
  557.     
  558.     if (GlobData.Board.x.y == opponent) then GlobData.pieces.opponent = GlobData.pieces.opponent - 1
  559.         
  560.     GlobData.Board.x.y = player
  561.     GlobData.pieces.player = GlobData.pieces.player + 1
  562.  
  563.     negone = -1    
  564.     return 1
  565.  
  566.  
  567.     
  568. SetStatus: procedure
  569.     parse arg newstatus
  570.     
  571.     if (newstatus == "_LAST") then do
  572.         SetWindowTitle '"' || getclip("PrevString") || '"'
  573.         end
  574.     else do
  575.         call setclip("PrevString",newstatus)
  576.         SetWindowTitle '"' || newstatus || '"'
  577.     end
  578.     return 1
  579.     
  580.  
  581.     
  582.     
  583.     
  584.  
  585. /* Returns the point midway between two coords */
  586. MidWayBetween: procedure expose GlobData.
  587.     parse arg left, right, XorY
  588.  
  589.     if (XorY = X) then 
  590.         return trunc((GlobData.XSpace.left + GlobData.XSpace.right)/2)
  591.     else    
  592.         return trunc((GlobData.YSpace.left + GlobData.YSpace.right)/2)
  593.  
  594. ChopRange: procedure
  595.     parse arg myval, lo, hi
  596.     if (myval < lo) then return lo
  597.     if (myval > hi) then return hi
  598.     return myval
  599.     
  600.     
  601. /* --------------------------------------------------------------- */
  602. /* procedure CheckForWin                                           */
  603. /* --------------------------------------------------------------- */
  604. CheckForWin: procedure expose GlobData.
  605.     winner = nobody
  606.     negone = -1
  607.     
  608.     if (GlobData.exited.1 == 15) then winner = "Player 1"
  609.     else if (GlobData.exited.negone == 15) then winner = "Player 2"
  610.     
  611.     /* nobody one yet */
  612.     if (winner == nobody) then return 1
  613.     
  614.     EasyRequest "Winner!" '"'||winner||" has won the game!"||'"' "Okay"
  615.     call SetStatus("Game Over.  Rerun the script to play again.")
  616.     lock off
  617.     exit
  618.     return 0
  619.     
  620.         
  621. /* Transmit our move to our opponent */
  622. TransmitMove: procedure 
  623.     parse arg x, y
  624.     
  625.     sstring = '"' || x || " " || y || '"'
  626.     sendmessage sstring
  627.     return 1
  628.     
  629.  
  630. /* procedure SetColors */
  631. SetColors: procedure
  632.     SetPenColor 0 10 10 10
  633.     SetPenColor 1 00 00 00
  634.     SetPenColor 2 15 15 15
  635.     SetPenColor 3 06 08 11
  636.     SetPenColor 4 09 09 09    /* This not used in 4-color screens; will be ignored then */
  637.     return 1
  638.